'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { ENUM, INTEGER, DATE, STRING, UUIDV4, UUID } = Sequelize;
    await queryInterface.createTable('goods_types', {
      uuid: {
        type: STRING(38),
        allowNull: false,
        primaryKey: true,
        defaultValue: UUIDV4,
      },
      created_at: DATE,
      updated_at: DATE,
      created_use_uuid: {
        type: UUID,
        allowNull: true,
        references: {
          model: 'users',
          key: 'uuid',
        },
        onUpdate: 'cascade',
        onDelete: 'cascade',
      },
      name: {
        type: STRING(128),
        allowNull: false,
        comment: "商品品类名",
      },
      intro: {
        type: STRING(255),
        allowNull: true,
        comment: "商品品类介绍",
      },
      parent_type_uuid: {
        type: STRING(38),
        allowNull: true,
        comment: "父类商品"
      },
      deleted: {
        type: ENUM('0', '1'),
        allowNull: false,
      },
      id: {
        type: INTEGER,
        allowNull: true
      }
    })
    
  },

  down: async (queryInterface, Sequelize) => {
     await queryInterface.dropTable("goods_types");
  }
};
